package com.bytetool.agent;

import com.bytetool.agent.config.AgentClientConfig;
import com.bytetool.agent.consumer.LoggerConsumer;
import com.bytetool.agent.transformer.ByteToolTransformer;
import com.bytetool.agent.util.LogsUtil;

import java.lang.instrument.Instrumentation;

/**
 * @author zouhuixing
 * @date 2024/3/31
 */
public class Main {

    public static void premain(String agentOps, Instrumentation instrumentation) {
        //避免文件打印出现空指针异常需要在加载配置文件后打印JavaAgent的启动文件
        LogsUtil.info("Start JavaAgent...");
        AgentClientConfig.setConfig(agentOps);
        LoggerConsumer.start();
        instrumentation.addTransformer(new ByteToolTransformer(agentOps));
    }
}
